package com.bawei.mall.user.contorller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.product.domain.model.MallUserCollectInfo;
import com.bawei.mall.product.domain.request.UserCollectList;
import com.bawei.mall.user.service.MallUserCollectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：张余庆
 * @Package：com.bawei.mall.user.contorller
 * @Project：mall_cloud
 * @name：MallUserCollectContorller
 * @Date：2024/7/4 13:54
 */
@RestController
@RequestMapping("/collect")
public class MallUserCollectContorller {

    @Autowired
    private MallUserCollectService service;

    /**
     * 功能：查询用户收藏表
     * @return
     */

    @GetMapping("/list")
    @ApiOperation("查询用户收藏表")
    public R<UserCollectList> list(@RequestParam(value = "pageNum") Integer pageNum,
                                             @RequestParam(value = "pageSize") Integer pageSize){
        UserCollectList list = service.list(pageNum,pageSize);
        return R.ok(list);
    }

    /**
     * 功能：清空用户的收藏表
     * @return
     */
    @PostMapping("clear")
    @ApiOperation("清空用户的收藏表")
    public R clear(){
        service.clear();
        return R.ok();
    }

    /**
     * 功能：添加用户收藏表
     * @return
     */
    @PostMapping("add")
    @ApiOperation("添加用户收藏表")
    public R add(@RequestBody MallUserCollectInfo mallUserCollectInfo){
        service.add(mallUserCollectInfo);
        return R.ok();
    }
}
